<?php
session_start();
include("../public/common.php");
include("../config/connect.php");

$catalog = trim(urldecode(CheckUrlParamNoDie("catalog")));
$gid = trim(CheckUrlParamNoDie("gid"));
$opt = trim(CheckUrlParamNoDie("opt"));
$wcl = trim(CheckUrlParamNoDie("wcl"));
$nPage = CheckUrlParamNoDie("page");
//$userid = HasLogin() ? $_COOKIE["gwt_userid"] : "";
$userid = isset($_COOKIE["gwt_userid"]) ? $_COOKIE["gwt_userid"] : "";

if ($nPage == "") $nPage = 1;
if($catalog == "") $catalog='电子数码';

//兑换商品跳订单页，如果未登录跳登录页面
if(!HasLogin() && $catalog != "" && $gid != "" && $opt== 'order')
{
	$url = "Location:../myservices/login.php?ref=".urlencode('http://www.gouwutu.com/dh/index.php?catalog='.$catalog.'&gid='.$gid.'&opt=order')."";
	header($url);
	exit;
}

if(HasLogin())
{
	$sql = "select id, tb_id, nick_name, tubi from user where id=$userid limit 1";
	$result = mysql_query( $sql );
	$row = mysql_fetch_assoc( $result );
	$userid = $row["id"];
	$nickname = $row["nick_name"];
	$tb_id = $row["tb_id"];
	$tubi = $row["tubi"];
}
if(isset($_POST["btn_buy"]))
{
	$tb_price = trim(GetPostParamStr("tb_price")); //单价
	$tb_bianma = trim(GetPostParamStr("tb_bianma")); //商品编码
	$tb_amount = trim(GetPostParamStr("tb_amount")); //购买数量
	$tb_address = trim(GetPostParamStr("tb_address")); //地址
	$tb_name = trim(GetPostParamStr("tb_name")); //姓名
	$tb_postcode = trim(GetPostParamStr("tb_postcode")); //邮编
	$tb_phone = trim(GetPostParamStr("tb_phone")); //联系电话
	$tb_memo = trim(GetPostParamStr("tb_memo"));  //备注
	$tb_needtubi = $tb_amount*$tb_price; //单价*数量=总付兔币
	$koutubi = $tubi-$tb_needtubi; //用户兔币 - 总付兔币 = 剩余兔币
	
	$row3 = mysql_fetch_assoc(mysql_query("select id, dhnumber,dhtitle,dhtag from gwt_dh_goods where id=$tb_bianma limit 1"));
	$dhtitle = $row3["dhtitle"];
	$gtag = $row3["dhtag"];
	$godid = $row3["id"];
	$dhnum = $row3["dhnumber"]; //商品数量
	$znum = $dhnum-$tb_amount; // 数量 - 购买数量 = 剩余数量
	
	//echo $znum.'********'.$koutubi;
	
	if($tb_needtubi > $tubi)
	{
		echo '<script>alert("您的兔币不足兑换此商品哦~~快去赚兔币吧~！");window.history.go(-1);</script>';
	}
	else if($dhnum < $tb_amount)
	{
		echo '<script>alert("请看看您兑换的商品数量是否充足或该商品已经兑换完了，请选择另一商品兑换！");window.history.go(-1);</script>';
	}
	else if($tb_amount != "" && $tb_name != "" && $tb_phone != "")
	{
		mysql_query("insert into gwt_dh_order (goods_id,user_id,buynum,needtubi,address,dhname,remark,hdphone,postcode) values ($tb_bianma, $userid, $tb_amount, $tb_needtubi, '$tb_address', '$tb_name', '$tb_memo','$tb_phone','$tb_postcode')");
		mysql_query("update gwt_dh_goods set dhnumber=$znum where id=$tb_bianma"); //购买一件该商品减少一件 
		mysql_query("update user set tubi=$koutubi where id=$userid");  //扣除该用户相应的兔币
		mysql_query("insert into gwt_msg (touser,content,typexx) values (".$userid.",'亲爱的".$nickname."，您使用<font color=".'#FF0000'.">".$tb_needtubi."</font>兔币兑换了<font color=".'#0000FF'.">".$tb_amount."</font>件<a href=".'../dh/index.php?catalog='."$gtag".'&gid='."$godid".''." target=".'_blank'." style=".'color:#FF0000'.">".$dhtitle."</a>，我们将在7天内给您发货，请您留意个人中心的发货消息。祝您在购物兔的每一天都能愉快！',2)");
	}
}

$row = mysql_fetch_assoc(mysql_query("select count(*) as tmp from gwt_dh_goods where dhtag='$catalog'"));
$allCount = $row["tmp"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=7" /> 
<title>商品兑换中心——购物兔，返现就这么简单</title>
<meta name ="keywords" content="返现,搜返现,返现简单,购物返现,返现最快,购物返利,网购返利,网购省钱,网购安全,安全购物,打折,折扣,省钱达人,购物达人,省钱省力省心"/>
<meta name="Description" content="购物兔致力于电子商务，旨在让您网购省钱省力更省心，购物兔特点是返现简单，返现最快，是您网购省钱、网购安全的第一选择。只需搜一搜，返现就这么简单！" />
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
<link type="text/css" rel="stylesheet" href="css/convert.css" />
<script language="javascript" src="http://www.gouwutu.com/new/js/jquery.min.js"></script>
<script type="text/javascript">
function sunbmintSS()
{
	var tbamount = document.getElementById("tb_amount").value; //数量
	//var tbaddress = document.getElementById("tb_address").value; //地址
	var tbname = document.getElementById("tb_name").value; //姓名
	var tbphone = document.getElementById("tb_phone").value; //联系
	var tbmemo = document.getElementById("tb_memo").value; //备注
	
	if (tbamount == "")
	{
		alert("请输入您要兑换几件商品~");
     	return false;
     }
	 if (tbname == "")
	{
		alert("请填写收件人姓名");
     	return false;
     }
	 if (tbphone == "")
	{
		alert("请输入收件人联系方式");
     	return false;
     }
	 
	return true;
}
</script>
</head>
<body>
<div id="header">
	<div class="head">
    	<div class="head_r">
        <?php
			if(!HasLogin())
			{
				echo '<span><a href="../myservices/login.php?id='.$userid.'&ref='.urlencode("http://www.gouwutu.com/dh/index.php").'">登录账号</a></span>';
			}
			else
			{
		?>
        	<span class="zhongxin"><?php echo $nickname; ?>，<a target="_blank" href="http://www.gouwutu.com/myservices/?id=<?php echo $userid; ?>">个人中心</a></span>
            <span class="jin"><font style="font-size:12px;"><?php echo $tubi; ?>兔币</font></span>
            <span class="tui"><a href="http://www.gouwutu.com/register_nocheck.php?opt=logout">[退出]</a></span>
         <?php 
			}
		 ?>
            <span>&nbsp;&nbsp;<a href="http://weibo.com/zhuhaigouwutu?wvr=4" target="_blank">新浪微博</a></span>
     	</div>
    </div>
    <div class="item mid">
        <h1 id="logo_img"><a href="http://www.gouwutu.com"><img title="购物兔，返现就这么简单" alt="购物兔，返现就这么简单" src="http://www.gouwutu.com/new/images/sslogo.gif"></a></h1>
        <div id="m">
            <p id="nv"></p>
            <div id="fm">
                <form action="http://www.gouwutu.com/new/s/" method="get" onsubmit="return Adjust('kw')" target="_blank">
                    <p class="gwt_ss"><input type="text" maxlength="1024" id="kw" name="q" autocomplete="on" onblur="if(this.value==''){this.value='输入您想要的宝贝名称或网址~';this.style.color = '#BABABA';}" onfocus="if(this.value=='输入您想要的宝贝名称或网址~'){this.value='';this.style.color = '#333';} this.select();" value="输入您想要的宝贝名称或网址~"></p>
                    <p class="btn_wr"><input type="submit" onmouseout="" onmousedown="" class="btn" id="su" value=""></p>
                    <input type="hidden" name="id" id="id" value="">
                    <input type="hidden" name="url" id="url" value="">
                </form>
            </div>
            <p class="tsearch-hot">
                <!-- 热门标签 -->
                <span>热门搜索：</span>
                 <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('羽绒服'); ?>" target="_blank">羽绒服</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('棉衣'); ?>" target="_blank">棉衣</a>
                <a class="h" href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('Tmall狂欢节'); ?>" target="_blank">Tmall狂欢节</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('靴子'); ?>" target="_blank">靴子</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('呢外套'); ?>" target="_blank">呢外套</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('大衣'); ?>" target="_blank">大衣</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('女包'); ?>" target="_blank">女包</a>
                <a href="http://www.gouwutu.com/new/s/?q=<?php echo urlencode('新款风衣'); ?>" target="_blank">新款风衣</a>
                <b class="gr-l"></b>
                <b class="gr-r"></b>
                <!--end-->
            </p>
        </div>
  	</div>
</div>
<div id="menu" class="mid" style="position:relative;">
	<div class="nav">
    	<ul>
        	<li><a href="http://www.gouwutu.com"><span>首页</span></a></li>
            <li <?php if($opt != 'rules' || $opt == '') echo ' class="as"'; ?>><a href="http://www.gouwutu.com/dh/index.php"><span>兑换商城</span></a></li>
            <li<?php if($opt == 'rules') echo ' class="as"'; ?>><a href="http://www.gouwutu.com/dh/index.php?opt=rules"><span>兔币兑换规则</span></a></li>
        </ul>
    </div>
    <div style="background:url(images/gb.gif) no-repeat; padding-left:55px; position:absolute; right:20px; top:0; height:35px; line-height:43px;"><a href="http://bbs.gouwutu.com/forum.php?mod=viewthread&tid=145" target="_blank" style="color:#03f; font-size:13px; font-weight:bold;">如何赚取更多的兔币？</a></div>
</div>
<div class="mid"><a href="http://www.gouwutu.com/new/activity/carnival.php" target="_blank" title="购物兔返利狂欢，拿双倍兔币，兑精品好礼，领现金红包！"><img src="http://www.gouwutu.com/new/images/gg/oxoxoxoxoxoxoxoxooxox.gif" width="950" alt="购物兔返利狂欢，拿双倍兔币，兑精品好礼，领现金红包！" /></a></div>
<div id="pu_frames" class="mid">
	<div id="pu_sublist">
    	<ul class="ul_pu">
            <li <?php if($catalog == '电子数码') echo ' class="ons"';?>><a href="?catalog=<?php echo urlencode('电子数码'); ?>">电子数码</a></li>
            <li <?php if($catalog == '家居礼品') echo ' class="ons"';?>><a href="?catalog=<?php echo urlencode('家居礼品'); ?>">家居礼品</a></li>
            <li <?php if($catalog == '生活实用') echo ' class="ons"';?>><a href="?catalog=<?php echo urlencode('生活实用'); ?>">生活实用</a></li>
            <li <?php if($catalog == '虚拟产品') echo ' class="ons"';?>><a href="?catalog=<?php echo urlencode('虚拟产品'); ?>">虚拟产品</a></li>
            <li <?php if($catalog == '真情回馈') echo ' class="ons"';?>><a style="color: red; font-weight: bolder;" href="?catalog=<?php echo urlencode('真情回馈'); ?>">真情回馈</a></li>
        </ul>
        <div id="pu_bues"><a class="ff60" href="#" style="display:none;">+more</a></div>
        <div id="pu_buylist">
<script type="text/javascript">
  var Marquee = function(id){
    try{document.execCommand("BackgroundImageCache", false, true);}catch(e){};
    var container = document.getElementById(id),
    original = container.getElementsByTagName("ul")[0],
    clone = container.getElementsByTagName("ol")[0],
    speed = arguments[1] || 50;
    clone.innerHTML=original.innerHTML;
    var rolling = function(){
      if(container.scrollTop == clone.offsetTop){
        container.scrollTop = 0;
      }else{
        container.scrollTop++;
      }
    }
    var timer = setInterval(rolling,speed)//设置定时器
    container.onmouseover=function() {clearInterval(timer)}//鼠标移到marquee上时，清除定时器，停止滚动
    container.onmouseout=function() {timer=setInterval(rolling,speed)}//鼠标移开时重设定时器
  }
  window.onload = function(){
    Marquee("marquee");
  }
</script> 
			<div id="marquee">
                <ul class="ul_buylist">
                <?php
                $sql = "select g.dhtag as tag,o.goods_id as gid,o.dtime as dtime,u.nick_name as oname, g.dhtitle as gtitle,u.tb_id as tbid from gwt_dh_order as o, gwt_dh_goods as g, user as u where o.goods_id=g.id and o.user_id=u.id order by o.id desc limit 10";
                //echo $sql;
                $result3 = mysql_query($sql);
                while( $result3 && $row = mysql_fetch_assoc( $result3 ))
                {
                ?>
                    <li><div class="splist"><a target="_blank" class="f090" href="../dh/index.php?catalog=<?php echo $row["tag"]; ?>&gid=<?php echo $row["gid"]; ?>" title="<?php echo $row["gtitle"]; ?>"><?php echo $row["gtitle"]; ?></a></div><div class="zhlist"><?php echo $row["oname"]; ?></div><div class="zhlist"><?php echo $row["dtime"]; ?></div></li>
                <?php
                }
                ?>
                </ul>
                <ol class="ul_buylist"></ol>
        	</div>
        </div>
    </div>
    <div id="pu_body">
<?php
	if($opt== 'rules')
	{
?> 
		<div id="pu_body_tit">兔币兑换规则</div>
        <div class="pu_boyd_mid">
        	<div style="padding:10px 15px 15px" class="showblock">
            	<p style="padding-top:10px;">
                	1、商品兑换仅限购物兔用户。登录后请选择商品进行兑换操作和填写寄件信息。为了使您兑换的商品及时准确地收到，请保证您填写的邮寄地址、邮编、收件人姓名、联系电话的准确性。商品的寄送仅限于中国大陆地区，同时请用中文填写。<br />
                    2、本次活动每个商品的兔币兑换都由购物兔承担运费，兑换用户无需添加邮费所需兔币<br />
                    3、商品图片仅供参考，具体商品以收到的实物为准；如果商品出现市场断货等情况，本站将会以同类同价值的商品替换；如收到商品与实际兑换商品不一致，商品有质量问题或者有损坏，请当场拒收并且退回，同时请与购物兔客服取得联系；如商品无质量问题，本公司不接受退还和更换，帐户兔币扣除后恕不返还。<br />
                    4、商品兑换成功后，本公司将安排尽快寄出，如果您在兑换后七天还没收到商品，请尽快与购物兔客服联系；如果兑换后十天内购物兔未接到您的投诉，本公司将默认为您已收到商品并无异议，并且将不再受理您的投诉。<br />
                    5、兑奖中心所有实物奖品发放最终解释权归购物兔所有！
                    <br>
                    <br>
                    备注：您在购物兔兑换商城里遇到任何问题请联系QQ:<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=2412491623&amp;site=qq&amp;menu=yes" target="_blank"><img border="0" align="absmiddle" title="欢迎点击和我们交流" src="http://wpa.qq.com/pa?p=2:2412491623:42" alt="点击和我们交流"></a>
                </p>
           </div>
      	</div>
<?php
	}else if($opt== 'success')
	{
?> 
		<div id="pu_body_tit">兑换成功</div>
        <div class="pu_boyd_mid" style="min-height:476px;">
        	<p style="color:#F90; font-size:14px; font-weight:bold; text-align:center; line-height:50px;">恭喜您！奖品订单已成功提交！</p>
            <p style="line-height:30px; text-align:center;"><a style="color:red;" href="http://bbs.gouwutu.com/forum.php?mod=viewthread&tid=145" target="_blank" title="还想兑换更多商品？没兔币？去赚兔币吧！">还想兑换更多商品？没兔币？去赚兔币吧！</a></p>
            <p style=" margin:0 12px;text-indent:10px; line-height:30px; border-bottom:2px solid #F60; font-weight:bold; color:#F90; font-size:14px;">你还可以看看其他商品！</p>
            <ul class="ul_p_list">
            <?php
			$sql = "select * from gwt_dh_goods where dhtag!='真情回馈' and dhnumber>=0 order by rand(now()) limit 6";
			$result2 = mysql_query($sql);
			while( $result2 && $row2 = mysql_fetch_assoc( $result2 ))
			{
			?>
              <li>
                	<p class="li_pic"><a href="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $row2["id"]; ?>" title="<?php echo $row2["dhtitle"]; ?>"><img src="<?php echo $row2["dhpic"]; ?>" alt="<?php echo $row2["dhtitle"]; ?>" /></a></p>
                    <p class="li_title"><a href="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $row2["id"]; ?>" title="<?php echo $row2["dhtitle"]; ?>"><?php echo $row2["dhtitle"]; ?></a></p>
                    <p class="li_money">兑换兔币：<font color="#FF0000"><?php echo $row2["tumoney"]; ?></font><img height="20" width="20" alt="兔币" src="images/jin.gif" title="兔币"></p>
                    <p class="li_num">剩余数量：<font color="#FF0000"><?php echo $row2["dhnumber"]; ?></font></p>
                </li>
             <?php } ?>
          	</ul>
        </div>
<?php 
	}else if($catalog != "" && $gid != "" && $opt== 'order')
	{
		//$sql = "select * from gwt_dh_goods where id=$gid limit 1";
		$row2 = mysql_fetch_assoc(mysql_query("select * from gwt_dh_goods where id=$gid limit 1"));
?>
		<div id="pu_body_tit">订单信息</div>
        <div class="pu_boyd_mid" style="min-height:476px;">
        	<div class="block_order">
            	<form id="Form1" action="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $gid; ?>&opt=success" method="post" name="Form1" onsubmit="return sunbmintSS()" >
        		<div class="showblock">
                    <p><span class="label">商品名称：</span><span class="val"><?php echo $row2["dhtitle"]; ?></span></p>
                    <p><span class="label">商品编码：</span><span class="val"><?php echo $row2["id"]; ?></span></p>
                    <p><span class="label">兑换兔币：</span><span class="val"><?php echo $row2["tumoney"]; ?></span>&nbsp;&nbsp;兔币</p>
                    <p><span class="label">兑换数量：</span><span class="val"><input type="text" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')" class="phone" id="tb_amount" value="" name="tb_amount" style="width:70px;"></span>&nbsp;&nbsp;&nbsp;该商品还剩余&nbsp;&nbsp;<font color="#00CC00"><?php echo $row2["dhnumber"]; ?></font>&nbsp;&nbsp;件</p>
                    <p><span class="label">收货人地址：</span><span class="val"><input type="text" id="tb_address" name="tb_address"></span></p>
                    <p><span class="label">收货人姓名：</span><span class="val"><input type="text" id="tb_name" name="tb_name"></span></p>
                    <p><span class="label">邮编：</span><span class="val"><input type="text" class="postcode" id="tb_postcode" name="tb_postcode"></span></p>
                    <p><span class="label">联系电话：</span><span class="val"><input type="text" class="phone" id="tb_phone" name="tb_phone"></span></p>
                    <p style="height:auto; line-height:20px;"><font color="#FF0000"><span class="label">注意：</span>如果您购买的是虚拟产品，请务必在备注里说明，例如充值的手机、QQ号等</font></p>
                    <p style="height:auto;"><span class="label">备注：</span><span class="val"><textarea id="tb_memo" name="tb_memo" style=" width:216px; height:60px; overflow:hidden; font-size:12px;"></textarea></span></p>
                    <input type="hidden" id="tb_price" name="tb_price" value="<?php echo $row2["tumoney"]; ?>" />
                    <input type="hidden" id="tb_bianma" name="tb_bianma" value="<?php echo $row2["id"]; ?>" />
                    <input type="hidden" id="tb_userid" name="tb_userid" value="<?php echo $row2["id"]; ?>" />
                    <p class="order_btn"><input type="submit" id="btn_buy" value="" name="btn_buy"></p>
                </div>
                </form>
			</div>
        </div>
<?php
	}else if($catalog != "" && $gid != "")
	{
		$row2 = mysql_fetch_assoc(mysql_query("select * from gwt_dh_goods where id=$gid limit 1"));
?>
		<div id="pu_body_tit"><?php echo $row2["dhtitle"]; ?></div>
        <div class="pu_boyd_mid">
       		<div class="showblock">
				<div class="product_basic">
					<div class="pic"><a target="_blank" href="#" title="<?php echo $row2["dhtitle"]; ?>"><img src="<?php echo $row2["dhpic"]; ?>" alt=""></a></div>
					<div class="desc">
						<h3><?php echo $row2["dhtitle"]; ?></h3>
						<p>商品编码：<?php echo $row2["id"]; ?><br>兑换价：<?php echo $row2["tumoney"]; ?><img width="20" height="20" title="兔币" src="images/jin.gif" alt="兔币"></p>
						<p class="tubi_dh"><a href="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $row2["id"]; ?>&opt=order" id="btn_buy">立即兑换</a></p>
					</div>
               	</div>
				<div class="product_intro">
					<h3>商品简介</h3>
					<p><?php echo $row2["dhintr"]; ?></p>
				</div>
			</div>
        </div>
        <div style="width:508px; border:1px solid #E3E3E3; margin-top:10px;">
        	<div class="showblock" style="padding:10px 15px 15px">
            	<div class="product_intro">
                	<h3>兑奖流程指南</h3>
                </div>
            	<p style="padding-top:10px;"><span class="xu">奖品寄送方式：</span><br>
                    虚拟产品兑奖审核通过后会直接充入您的手机或QQ账号中（请在备注中填写您需要充值的手机、QQ号码，QQ增值服务请填写清楚所需QQ服务，如：红钻）；实体奖品全部采用快递方式。<br>
                    <span class="xu">奖品兑换流程：</span><br>
                    1、本次活动兑换商品均由购物兔承担运费，您无需另行支付。兑奖前请确认您的帐户中有足够数量的兔币！<br>
                    2、在您要兑奖的奖品页面点击"兔币兑换"按钮，提交您的兑奖申请！<br>
                    3、确认您的奖品邮寄地址、姓名，联系电话正确无误后提交兑奖申请 ！
    
                    <br>
                    4、实物奖品将在您的兑奖确认后的7工作日内发出(奖品状态您可在个人中心的“消息”使用物流编号查询)！<br>
                    5、兑奖中心所有实物奖品发放最终解释权归购物兔所有！
                    <br>
                    <br>
                    备注：您在购物兔兑换商城里遇到任何问题请联系QQ:<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=2412491623&amp;site=qq&amp;menu=yes" target="_blank"><img border="0" align="absmiddle" title="欢迎点击和我们交流" src="http://wpa.qq.com/pa?p=2:2412491623:42" alt="点击和我们交流"></a>
                </p>
            </div>
        </div>
<?php
	}else{
?>
    	<div id="pu_body_tit"><?php echo $catalog; ?></div>
        <div class="pu_boyd_mid" style="min-height:476px;">
        	<ul class="ul_p_list">
            <?php
				$PAGE_SIZE = 6; //每页数量
            	$limit = " limit ". ($nPage-1)*$PAGE_SIZE .",$PAGE_SIZE";
            	$sql = "select * from gwt_dh_goods where dhtag='$catalog' and dhnumber>=0 order by tumoney desc".$limit;
				$result2 = mysql_query($sql);
				while( $result2 && $row2 = mysql_fetch_assoc( $result2 ))
				{
			?>
            	<li>
                	<p class="li_pic"><a href="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $row2["id"]; ?>" title="<?php echo $row2["dhtitle"]; ?>"><img src="<?php echo $row2["dhpic"]; ?>" alt="<?php echo $row2["dhtitle"]; ?>" /></a></p>
                    <p class="li_title"><a href="?catalog=<?php echo urlencode($catalog); ?>&gid=<?php echo $row2["id"]; ?>" title="<?php echo $row2["dhtitle"]; ?>"><?php echo $row2["dhtitle"]; ?></a></p>
                    <p class="li_money">兑换兔币：<font color="#FF0000"><?php echo $row2["tumoney"]; ?></font><img width="20" height="20" title="兔币" src="images/jin.gif" alt="兔币"></p>
                    <p class="li_num">剩余数量：<font color="#FF0000"><?php echo $row2["dhnumber"]; ?></font></p>
                </li>
           	<?php
				}
			?>
            </ul>
            <div id="pu_dht">
            <?PHP if ($allCount > $PAGE_SIZE) { ?>
				<div id="Pager1">
				 <?php	
                    $all_page = ceil($allCount / $PAGE_SIZE);
                    if ($nPage > 1) echo "<a class='pageNext' href='?page=".($nPage-1)."&catalog=$catalog'>上一页</a>";
                    
                    if($all_page<=12){				
                        for($i=1;$i<=$all_page;$i++){//数字分页
                            $Pageshow = ($i!=$nPage)?"<a href='?page=$i&catalog=$catalog'>".($i)."</a>":"<b>".($i)."</b>";
                            echo $Pageshow;
                        }
                    }else{
                        for($i=1;$i<=12;$i++){//数字分页
                            $Pageshow = ($i!=$nPage)?"<a href='?page=$i&catalog=$catalog'>".($i)."</a>":"<b>".($i)."</b>";
                            echo $Pageshow;
                        }
                    }
                    
                    if($nPage == 12 || $nPage == $all_page){
                        echo "";
                    }else if($nPage < 12){
                        echo "<a class='pageNext' href='?page=".($nPage+1)."&catalog=$catalog'>下一页</a>";
                    }
                     ?>
                </div>
            <?php
			}
			?>                          
        	</div>
        </div>
<?php 
	}
?>
    </div>
    <div id="pu_subpath">
    	<div>
        	<iframe width="100%" height="440"frameborder="0" scrolling="no" src="http://widget.weibo.com/livestream/listlive.php?language=zh_cn&width=0&height=440&uid=1972429953&skin=1&refer=1&pic=1&titlebar=1&border=1&publish=1&atalk=1&recomm=0&at=0&atopic=%E3%80%90%E8%B4%AD%E7%89%A9%E5%85%94%E3%80%91%E6%88%91%E6%9D%A5%E8%AF%B4%E5%85%91%E6%8D%A2&ptopic=%E3%80%90%E8%B4%AD%E7%89%A9%E5%85%94%E3%80%91%E6%88%91%E6%9D%A5%E8%AF%B4%E5%85%91%E6%8D%A2&colordiy=0&dpc=1"></iframe>
        </div>
        <div id="pu_hot_3" style="padding-top:20px; overflow:hidden;"><a href="index.php?opt=rules"><img src="images/dhgzpic.jpg" alt="兔币兑换规则" title="兔币兑换规则" /></a></div>
    </div>
</div>
<?php
include("../new/ft.php");
?>
</body>
</html>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-20984072-1");
pageTracker._trackPageview();
} catch(err) {}</script>

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F7eb75a7b189f4a709dead85bc20eb0dd' type='text/javascript'%3E%3C/script%3E"));
</script>

